home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc263-src.lha / gcc-2.6.3 / config / svr3.h < prev    next >
C/C++ Source or Header  |  1994-07-29  |  12KB  |  385 lines

  1. /* svr3.h  --  operating system specific defines to be used when
  2.    targeting GCC for some generic System V Release 3 system.
  3.    Copyright (C) 1991 Free Software Foundation, Inc.
  4.  
  5.    Written by Ron Guilmette (rfg@netcom.com).
  6.  
  7. This file is part of GNU CC.
  8.  
  9. GNU CC is free software; you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation; either version 2, or (at your option)
  12. any later version.
  13.  
  14. GNU CC is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with GNU CC; see the file COPYING.  If not, write to
  21. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23.    To use this file, make up a file with a name like:
  24.  
  25.     ?????svr3.h
  26.  
  27.    where ????? is replaced by the name of the basic hardware that you
  28.    are targeting for.  Then, in the file ?????svr3.h, put something
  29.    like:
  30.  
  31.     #include "?????.h"
  32.     #include "svr3.h"
  33.  
  34.    followed by any really system-specific defines (or overrides of
  35.    defines) which you find that you need.  For example, CPP_PREDEFINES
  36.    is defined here with only the defined -Dunix and -DSVR3.  You should
  37.    probably override that in your target-specific ?????svr3.h file
  38.    with a set of defines that includes these, but also contains an
  39.    appropriate define for the type of hardware that you are targeting.
  40. */
  41.  
  42. /* Define a symbol indicating that we are using svr3.h.  */
  43. #define USING_SVR3_H
  44.  
  45. /* Define a symbol so that libgcc* can know what sort of operating
  46.    environment and assembler syntax we are targeting for.  */
  47. #define SVR3_target
  48.  
  49. /* Cpp, assembler, linker, library, and startfile spec's.  */
  50.  
  51. /* You should redefine CPP_PREDEFINES in any file which includes this one.
  52.    The definition should be appropriate for the type of target system
  53.    involved, and it should include any -A (assertion) options which are
  54.    appropriate for the given target system.  */
  55.  
  56. #undef CPP_PREDEFINES
  57.  
  58. /* Output at beginning of assembler file.  */
  59. /* The .file command should always begin the output.  */
  60.  
  61. #undef ASM_FILE_START
  62. #define ASM_FILE_START(FILE)                    \
  63.   do { output_file_directive ((FILE), main_input_filename);    \
  64.        if (optimize) ASM_FILE_START_1 (FILE);            \
  65.      } while (0)
  66.  
  67. /* By default, do nothing: a few machines support .optim, but not most.  */
  68. #undef ASM_FILE_START_1
  69. #define ASM_FILE_START_1(FILE)
  70.  
  71. /* This says how to output an assembler line
  72.    to define a global common symbol.  */
  73. /* We don't use ROUNDED because the standard compiler doesn't,
  74.    and the linker gives error messages if a common symbol
  75.    has more than one length value.  */
  76.  
  77. #undef ASM_OUTPUT_COMMON
  78. #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
  79. ( fputs (".comm ", (FILE)),            \
  80.   assemble_name ((FILE), (NAME)),        \
  81.   fprintf ((FILE), ",%u\n", (SIZE)))
  82.  
  83. /* This says how to output an assembler line
  84.    to define a local common symbol.  */
  85.  
  86. /* Note that using bss_section here caused errors
  87.    in building shared libraries on system V.3.  */
  88. #undef ASM_OUTPUT_LOCAL
  89. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)    \
  90.   do {                            \
  91.     int align = exact_log2 (ROUNDED);            \
  92.     if (align > 2) align = 2;                \
  93.     data_section ();                    \
  94.     ASM_OUTPUT_ALIGN ((FILE), align == -1 ? 2 : align);    \
  95.     ASM_OUTPUT_LABEL ((FILE), (NAME));            \
  96.     fprintf ((FILE), "\t.set .,.+%u\n", (ROUNDED));    \
  97.   } while (0)
  98.  
  99. #if 0 /* For now, let's leave these machine-specific.  */
  100. /* Use crt1.o as a startup file and crtn.o as a closing file.  */
  101.  
  102. #define STARTFILE_SPEC  \
  103.   "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}"
  104.  
  105. #define LIB_SPEC "%{p:-L/usr/lib/libp}%{pg:-L/usr/lib/libp} -lc crtn.o%s"
  106.  
  107. /* Special flags for the linker.  I don't know what they do.  */
  108.  
  109. #define LINK_SPEC "%{T*} %{z:-lm}"
  110. #endif
  111.  
  112. /* Allow #sccs in preprocessor.  */
  113.  
  114. #define SCCS_DIRECTIVE
  115.  
  116. /* Output #ident as a .ident.  */
  117.  
  118. #define ASM_OUTPUT_IDENT(FILE, NAME) \
  119.   fprintf (FILE, "\t.ident \"%s\"\n", NAME);
  120.  
  121. /* Use periods rather than dollar signs in special g++ assembler names.  */
  122.  
  123. #define NO_DOLLAR_IN_LABEL
  124.  
  125. /* Implicit library calls should use memcpy, not bcopy, etc.  */
  126.  
  127. #define TARGET_MEM_FUNCTIONS
  128.  
  129. /* System V Release 3 uses COFF debugging info.  */
  130.  
  131. #define SDB_DEBUGGING_INFO
  132.  
  133. /* We don't want to output DBX debugging information.  */
  134.  
  135. #undef DBX_DEBUGGING_INFO
  136.  
  137. /* Define the actual types of some ANSI-mandated types.  These
  138.    definitions should work for most SVR3 systems.  */
  139.  
  140. #undef SIZE_TYPE
  141. #define SIZE_TYPE "unsigned int"
  142.  
  143. #undef PTRDIFF_TYPE
  144. #define PTRDIFF_TYPE "int"
  145.  
  146. #undef WCHAR_TYPE
  147. #define WCHAR_TYPE "long int"
  148.  
  149. #undef WCHAR_TYPE_SIZE
  150. #define WCHAR_TYPE_SIZE BITS_PER_WORD
  151.  
  152. /* Assembler pseudos to introduce constants of various size.  These
  153.    definitions hsould work for most svr3 systems.  */
  154.  
  155. #undef ASM_BYTE_OP
  156. #define ASM_BYTE_OP "\t.byte"
  157.  
  158. /* This is how to output a reference to a user-level label named NAME.
  159.    `assemble_name' uses this.
  160.  
  161.    For System V Release 3 the convention is to prepend a leading
  162.    underscore onto user-level symbol names.  */
  163.  
  164. #undef ASM_OUTPUT_LABELREF
  165. #define ASM_OUTPUT_LABELREF(FILE,NAME) fprintf (FILE, "_%s", NAME)
  166.  
  167. /* This is how to output an internal numbered label where
  168.    PREFIX is the class of label and NUM is the number within the class.
  169.  
  170.    For most svr3 systems, the convention is that any symbol which begins
  171.    with a period is not put into the linker symbol table by the assembler.  */
  172.  
  173. #undef ASM_OUTPUT_INTERNAL_LABEL
  174. #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM)    \
  175.   asm_fprintf (FILE, "%0L%s%d:\n", PREFIX, NUM)
  176.  
  177. /* This is how to store into the string LABEL
  178.    the symbol_ref name of an internal numbered label where
  179.    PREFIX is the class of label and NUM is the number within the class.
  180.    This is suitable for output with `assemble_name'.
  181.  
  182.    For most svr3 systems, the convention is that any symbol which begins
  183.    with a period is not put into the linker symbol table by the assembler.  */
  184.  
  185. #undef ASM_GENERATE_INTERNAL_LABEL
  186. #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)    \
  187.   sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM)
  188.  
  189. /* We want local labels to start with period if made with asm_fprintf.  */
  190. #undef LOCAL_LABEL_PREFIX
  191. #define LOCAL_LABEL_PREFIX "."
  192.  
  193. /* Support const sections and the ctors and dtors sections for g++.
  194.    Note that there appears to be two different ways to support const
  195.    sections at the moment.  You can either #define the symbol
  196.    READONLY_DATA_SECTION (giving it some code which switches to the
  197.    readonly data section) or else you can #define the symbols
  198.    EXTRA_SECTIONS, EXTRA_SECTION_FUNCTIONS, SELECT_SECTION, and
  199.    SELECT_RTX_SECTION.  We do both here just to be on the safe side.
  200.    However, use of the const section is turned off by default
  201.    unless the specific tm.h file turns it on by defining
  202.    USE_CONST_SECTION as 1.  */
  203.  
  204. /* Define a few machine-specific details of the implementation of
  205.    constructors.
  206.  
  207.    The __CTORS_LIST__ goes in the .init section.  Define CTOR_LIST_BEGIN
  208.    and CTOR_LIST_END to contribute to the .init section an instruction to
  209.    push a word containing 0 (or some equivalent of that).
  210.  
  211.    Define ASM_OUTPUT_CONSTRUCTOR to push the address of the constructor.  */
  212.  
  213. #define USE_CONST_SECTION    0
  214.  
  215. #define INIT_SECTION_ASM_OP     ".section\t.init"
  216. #define FINI_SECTION_ASM_OP     ".section .fini,\"x\""
  217. #define CONST_SECTION_ASM_OP    ".section\t.rodata, \"x\""
  218. #define CTORS_SECTION_ASM_OP    INIT_SECTION_ASM_OP
  219. #define DTORS_SECTION_ASM_OP    FINI_SECTION_ASM_OP
  220.  
  221. /* CTOR_LIST_BEGIN and CTOR_LIST_END are machine-dependent
  222.    because they push on the stack.  */
  223.  
  224. #ifndef STACK_GROWS_DOWNWARD
  225.  
  226. /* Constructor list on stack is in reverse order.  Go to the end of the
  227.    list and go backwards to call constructors in the right order.  */
  228. #define DO_GLOBAL_CTORS_BODY                    \
  229. do {                                \
  230.   func_ptr *p, *beg = alloca (0);                \
  231.   for (p = beg; *p; p++)                    \
  232.     ;                                \
  233.   while (p != beg)                        \
  234.     (*--p) ();                            \
  235. } while (0)
  236.  
  237. #else
  238.  
  239. /* Constructor list on stack is in correct order.  Just call them.  */
  240. #define DO_GLOBAL_CTORS_BODY                    \
  241. do {                                \
  242.   func_ptr *p, *beg = alloca (0);                \
  243.   for (p = beg; *p; )                        \
  244.     (*p++) ();                            \
  245. } while (0)
  246.  
  247. #endif /* STACK_GROWS_DOWNWARD */
  248.  
  249. /* Add extra sections .init and .fini, in addition to .bss from att386.h. */
  250.  
  251. #undef EXTRA_SECTIONS
  252. #define EXTRA_SECTIONS in_const, in_bss, in_init, in_fini
  253.  
  254. #undef EXTRA_SECTION_FUNCTIONS
  255. #define EXTRA_SECTION_FUNCTIONS                    \
  256.   CONST_SECTION_FUNCTION                    \
  257.   BSS_SECTION_FUNCTION                        \
  258.   INIT_SECTION_FUNCTION                        \
  259.   FINI_SECTION_FUNCTION
  260.  
  261. #define BSS_SECTION_FUNCTION                    \
  262. void                                \
  263. bss_section ()                            \
  264. {                                \
  265.   if (in_section != in_bss)                    \
  266.     {                                \
  267.       fprintf (asm_out_file, "\t%s\n", BSS_SECTION_ASM_OP);    \
  268.       in_section = in_bss;                    \
  269.     }                                \
  270. }
  271.  
  272. #define INIT_SECTION_FUNCTION                    \
  273. void                                \
  274. init_section ()                            \
  275. {                                \
  276.   if (in_section != in_init)                    \
  277.     {                                \
  278.       fprintf (asm_out_file, "\t%s\n", INIT_SECTION_ASM_OP);    \
  279.       in_section = in_init;                    \
  280.     }                                \
  281. }
  282.  
  283. #define FINI_SECTION_FUNCTION                    \
  284. void                                \
  285. fini_section ()                            \
  286. {                                \
  287.   if (in_section != in_fini)                    \
  288.     {                                \
  289.       fprintf (asm_out_file, "\t%s\n", FINI_SECTION_ASM_OP);    \
  290.       in_section = in_fini;                    \
  291.     }                                \
  292. }
  293.  
  294. #define READONLY_DATA_SECTION() const_section ()
  295.  
  296. #define CONST_SECTION_FUNCTION                        \
  297. void                                    \
  298. const_section ()                            \
  299. {                                    \
  300.   extern void text_section();                        \
  301.   if (!USE_CONST_SECTION)                        \
  302.     text_section();                            \
  303.   else if (in_section != in_const)                    \
  304.     {                                    \
  305.       fprintf (asm_out_file, "%s\n", CONST_SECTION_ASM_OP);        \
  306.       in_section = in_const;                        \
  307.     }                                    \
  308. }
  309.  
  310. /* The ctors and dtors sections are not normally put into use 
  311.    by EXTRA_SECTIONS and EXTRA_SECTION_FUNCTIONS as defined in svr3.h,
  312.    but it can't hurt to define these macros for whatever systems use them.  */
  313. #define CTORS_SECTION_FUNCTION                        \
  314. void                                    \
  315. ctors_section ()                            \
  316. {                                    \
  317.   if (in_section != in_ctors)                        \
  318.     {                                    \
  319.       fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP);        \
  320.       in_section = in_ctors;                        \
  321.     }                                    \
  322. }
  323.  
  324. #define DTORS_SECTION_FUNCTION                        \
  325. void                                    \
  326. dtors_section ()                            \
  327. {                                    \
  328.   if (in_section != in_dtors)                        \
  329.     {                                    \
  330.       fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP);        \
  331.       in_section = in_dtors;                        \
  332.     }                                    \
  333. }
  334.  
  335. /* This is machine-dependent
  336.    because it needs to push something on the stack.  */
  337. #undef ASM_OUTPUT_CONSTRUCTOR
  338.  
  339. /* A C statement (sans semicolon) to output an element in the table of
  340.    global destructors.  */
  341. #define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)                       \
  342.   do {                                    \
  343.     fini_section ();                                   \
  344.     fprintf (FILE, "%s\t ", ASM_LONG);                    \
  345.     assemble_name (FILE, NAME);                              \
  346.     fprintf (FILE, "\n");                        \
  347.   } while (0)
  348.  
  349. /* A C statement or statements to switch to the appropriate
  350.    section for output of DECL.  DECL is either a `VAR_DECL' node
  351.    or a constant of some sort.  RELOC indicates whether forming
  352.    the initial value of DECL requires link-time relocations.  */
  353.  
  354. #define SELECT_SECTION(DECL,RELOC)                    \
  355. {                                    \
  356.   if (TREE_CODE (DECL) == STRING_CST)                    \
  357.     {                                    \
  358.       if (! flag_writable_strings)                    \
  359.     const_section ();                        \
  360.       else                                \
  361.     data_section ();                        \
  362.     }                                    \
  363.   else if (TREE_CODE (DECL) == VAR_DECL)                \
  364.     {                                    \
  365.       if ((0 && RELOC)    /* should be (flag_pic && RELOC) */        \
  366.       || !TREE_READONLY (DECL) || TREE_SIDE_EFFECTS (DECL)        \
  367.       || !DECL_INITIAL (DECL)                    \
  368.       || (DECL_INITIAL (DECL) != error_mark_node            \
  369.           && !TREE_CONSTANT (DECL_INITIAL (DECL))))            \
  370.     data_section ();                        \
  371.       else                                \
  372.     const_section ();                        \
  373.     }                                    \
  374.   else                                    \
  375.     const_section ();                            \
  376. }
  377.  
  378. /* A C statement or statements to switch to the appropriate
  379.    section for output of RTX in mode MODE.  RTX is some kind
  380.    of constant in RTL.  The argument MODE is redundant except
  381.    in the case of a `const_int' rtx.  Currently, these always
  382.    go into the const section.  */
  383.  
  384. #define SELECT_RTX_SECTION(MODE,RTX) const_section()
  385.